package com.qf.mvc01.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
@RequestMapping("/user")
public class LoginController {

    @RequestMapping("/login")
    public void test1(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //1.设置编码格式
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        //2.收参
        String value = request.getParameter("value");
        //3.与数据库进行数据比较
        String  result = null;
        if (value.equals("root") | value.equals("admin")) {
            result = "2";
            //代表已经存在
        }else{
            //可以注册
            result = "1";
        }
        //4.响应数据
        response.getWriter().print(result);
    }
}
